<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>회원가입</title>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
function check() {
	if(document.frm2.mem_pwd.value == "") {
		alert("비밀번호를 입력해주세요.");
		document.frm2.mem_pwd.focus();
		return;
	}
	if(document.frm2.mem_pwd2.value == "") {
		alert("비밀번호 확인을 꼭 입력하세요!");
		document.frm2.mem_pwd2.focus();
		return;
	}
	if(document.frm2.mem_pwd.value != document.frm2.mem_pwd2.value) {
		alert("비밀번호와 비밀번호 확인이 일치하지않습니다!");
		document.frm2.mem_pwd.value = "";
		document.frm2.mem_pwd2.value = "";
		document.frm2.mem_pwd.focus();
	}
	if(document.frm2.mem_name.value == "") {
		alert("이름을 꼭 입력하세요!");
		document.frm2.mem_name.focus();
		return;
	}
	if(document.frm2.mem_email.value == "") {
		alert("Email을 꼭 입력하세요!");
		document.frm2.mem_email.focus();
		return;
	}

	if(document.frm2.mem_addr.value == "") {
		alert("주소를 꼭 입력하세요!");
		document.frm2.addr.focus();
		return;
	}

	if(document.frm2.hp1.value == "--") {
		alert("핸드폰 1번째 값을 입력하세요!");
		document.frm2.hp1.focus();
		return;
	}
	if(document.frm2.hp2.value == "") {
		alert("핸드폰 2번째 값을 입력하세요!");
		document.frm2.hp2.focus();
		return;
	}
	if(document.frm2.hp3.value == "") {
		alert("핸드폰 3번째 값을 입력하세요!");
		document.frm2.hp3.focus();
		return;
	}
	if(document.frm2.mem_job.value == "--") {
		alert("직업을 꼭 선택하세요!");
		document.frm2.mem_job.focus();
		return;
	}
	document.frm2.mem_hp.value =
		document.frm2.hp1.value + "-"
		+ document.frm2.hp2.value + "-"
		+ document.frm2.hp3.value;
	//alert("핸드폰="+document.frm.hp.value);
	document.frm2.submit(); //  전송
}
</script>
</head>
<body>
<form name="frm2" action="member/update.htm" method="post">
	<table border="0" cellspacing="0" cellpadding="2" width="700">
		<tr><th colspan="2" align="center" bgcolor="#004554"><font color="#FFFFFF">회원 정보 수정</font></th></tr>
		<tr><td height="20"></td></tr>
		<tr>
			<th align="left" height="40">아이디</th>
			<td align="left">
			<input type="text" value="${mem.mem_id}" id="mem_id" name="mem_id" size="20" readonly="readonly">
			</td>
		</tr>	
		<tr>
			<th align="left" height="40">비밀번호</th>
			<td align="left"><input type="password" id="mem_pwd" name="mem_pwd" size="20"></td>
		</tr>
		<tr>
			<th align="left" height="40">비밀번호 확인</th>
			<td align="left"><input type="password" id="mem_pwd2" name="mem_pwd2" size="20"></td>
		</tr>
		<tr>
			<th align="left" height="40">이 름</th>
			<td align="left"><input type="text" value="${mem.mem_name}" id="mem_name" name="mem_name" size="10"></td>
		</tr>
		<tr>
			<th align="left" height="40">주 소</th>
			<td align="left"><input type="text" value="${mem.mem_addr}" id="mem_addr" name="mem_addr" size="60"></td>
		</tr>
		<tr>
			<th align="left" height="40">연락처</th>
			<td align="left">
				<input type="hidden" id="mem_hp" name="mem_hp">
				<c:set var="hp" value="${fn:split(mem.mem_hp, '-')}" />
				<c:set var="sel" value="selected='selected'" />
				<select id="hp1" name="hp1">
					<option value="--">--
					<option value="010" ${hp[0] == '010' ? sel : ""}>010
					<option value="011" ${hp[0] == '011' ? sel : ""}>011
					<option value="016" ${hp[0] == '016' ? sel : ""}>016
					<option value="017" ${hp[0] == '017' ? sel : ""}>017
					<option value="018" ${hp[0] == '018' ? sel : ""}>018
					<option value="019" ${hp[0] == '019' ? sel : ""}>019
				</select>
			- <input type="text" id="hp2" name="hp2" value="${hp[1]}" size="4" maxlength="4">
			- <input type="text" id="hp3" name="hp3" value="${hp[2]}" size="4" maxlength="4">
			</td>
		</tr>
		<tr>
			<th align="left" height="40">E-mail</th>
			<td align="left"><input type="text" value="${mem.mem_email}" id="mem_email" name="mem_email" size="30"></td>
		</tr>
		<tr>
			<th align="left" height="40">직업</th>
			<td align="left">
				<select id="mem_job" name="mem_job">
					<option value="--">--
					<option value="직장인" ${mem.mem_job == "직장인" ? sel : ""}>직장인
					<option value="자영업" ${mem.mem_job == "자영업" ? sel : ""}>자영업
					<option value="학생" ${mem.mem_job == "학생" ? sel : ""}>학생
					<option value="기타" ${mem.mem_job == "기타" ? sel : ""}>기타
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
			<br>
			<input type="button" value="수정" onclick="check()">
			<input type="reset" value="취소"><br><br>
			<a href="#" onclick="window.document.location.reload()">돌아가기</a>
			</td>
		</tr>
	</table>
</form>
</body>
</html>